package
{

	import flash.display.MovieClip;

public dynamic class Teabag extends MovieClip
{
    var grav: Number = 1.2;
    var hasHit: Boolean = false;
    var hitSomeone: Boolean = false;
	/*
    var _name;
    var _parent;
    var _x;
    var _xscale;
    var _y;
	*/
    var num;
    var xv;
    var yv;

    function Teabag()
    {
        super();
    }

    function init()
    {
        this.num = Number(this.name.substr(3, this.name.length - 3));
        this.xv = this.yv = 0;
        if (this.x < 285) 
        {
            this.scaleX = -100;
        }
    }

    function EF()
    {
        this.x = this.x + this.xv;
        this.y = this.y + this.yv;
        this.yv = this.yv + this.grav;
        if (this.parent.parent.ground.hitTest(this.x, this.y, true)) 
        {
            if (this.x > 288) 
            {
                if (this.xv < 4) 
                {
                    this.xv = 3.5;
                }
            }
            else if (this.xv > -4) 
            {
                this.xv = -3.5;
            }
            this.yv = -2;
            if (!this.hasHit) 
            {
                this.hasHit = true;
            }
        }
        if (this.x < -10 || this.x > 610 || this.y > 460) 
        {
            this.parent.parent.removeObject(this);
        }
        var __reg2 = this.parent.parent.checkEnemyHit(this);
        if (__reg2.length > 0) 
        {
            if (!this.hitSomeone) 
            {
                this.hitSomeone = true;
                SoundManager.startSound("avalanche");
            }
            var __reg3 = this.xv;
            for (var __reg4 in __reg2) 
            {
                __reg2[__reg4].knockDown(__reg3);
            }
        }
    }

}


}